using System;
using System.Collections.Generic;
using UnityEngine;

public class C_弓箭 : MonoBehaviour
{
	[SerializeField]
	private Rigidbody2D _RB2D;

	public float _击退力度 = 5f;

	public int _阵营;

	public float _伤害 = 10f;

	public float _僵直伤害;

	public Transform _Tsf_Model;

	public Transform _Tsf_影子;

	public Collider2D _Col2D;

	private HashSet<IBeAttack> _Hsah_本次受击人员 = new HashSet<IBeAttack>();

	private float _speed = 20f;

	public event Action _攻击命中回调 = delegate
	{
	};

	public void F_Init(Vector2 dir, float 攻击力)
	{
		_Tsf_Model.right = dir;
		_Tsf_影子.right = dir;
		_RB2D.velocity = dir * _speed;
		_伤害 = 攻击力;
		Invoke("F_销毁", 5f);
	}

	private void F_销毁()
	{
		UnityEngine.Object.Destroy(base.gameObject);
	}

	private void OnEnable()
	{
		_Hsah_本次受击人员.Clear();
	}

	private void OnTriggerEnter2D(Collider2D collision)
	{
		if (!(collision.tag != "Player") && collision.TryGetComponent<IBeAttack>(out var component) && component._阵营 != _阵营 && !_Hsah_本次受击人员.Contains(component))
		{
			this._攻击命中回调();
			_Hsah_本次受击人员.Add(component);
			component?.BeAttack(_伤害, _僵直伤害, _击退力度, base.transform.position, atk_Is远程: true);
			UnityEngine.Object.Destroy(base.gameObject);
		}
	}
}
